package org.flynenu.core.dao.session;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class SessionBuilderImpl implements SessionBuilder {
	private String xmlPath = null;
	
	private static SessionFactory sessionFactory = null;
	
	public void setXmlPath(String xmlPath) {
		this.xmlPath = xmlPath;
	}
	
	@Override
	public Session buildeSession() {
		if(sessionFactory == null)
			sessionFactory = new Configuration().configure(xmlPath).buildSessionFactory();
		
		return sessionFactory.openSession();
	}
}
